#!  python
# -*- coding: UTF-8 -*-
'''
@Author ：Star
@Date ：2022/10/18  
'''

from selenium import webdriver

from selenium.webdriver.common.action_chains import ActionChains

from selenium.webdriver.common.by import By
from time import sleep

from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select
import random
from selenium.webdriver.support import expected_conditions as EC

op = webdriver.ChromeOptions()
op.add_experimental_option("excludeSwitches", ["enable-automation"])
op.add_experimental_option("useAutomationExtension", False)
driver = webdriver.Chrome(options=op)
driver.get(r"https://jqueryui.com/slider/#hotelrooms")
sleep(2)
iframe = driver.find_element(By.CSS_SELECTOR,".demo-frame")
driver.switch_to.frame(iframe)
randomNum = random.randint(1,5)
print(randomNum)

sliding = driver.find_element(By.CSS_SELECTOR,"#slider > span")
ActionChains(driver).drag_and_drop_by_offset(sliding,80*randomNum,0).perform()  #鼠标拖拽滑块
sleep(3)

randomNum2 = random.randint(1,5)
select = driver.find_element(By.CSS_SELECTOR,"#minbeds")
Select(select).select_by_index(randomNum2)    #下拉选择
sleep(2)
print("success")
driver.quit()



